/*
* Revision of last commit: $Rev$
* Author of last commit: $Author$
* Date of last commit: $Date$
*/

#ifndef _ASSERT_H_INCLUDED_
#define _ASSERT_H_INCLUDED_

#include <string>
#include <sstream>
#include "CommonExceptions.h"

//clear standart macro
#ifdef assert
#undef assert
#endif

//and replace with new one
#ifdef _DEBUG
#define assert(expr) \
if (!(expr)) \
{ \
	std::ostringstream convert; \
	convert << __LINE__; \
	throw Core::Cmn::AssertException(std::string("Assertion failed\nIn file ") \
		+ std::string(__FILE__) + "\nOn line " + convert.str() + "\nFunction name " + std::string(__FUNCTION__));  \
}
#else
#define assert(expr)
#endif

namespace Core
{
namespace Cmn
{

/**
@brief Assert exception is thrown when assertion is corrupted.
@descr Standart assert in assert.h header forces application
	   to abort without neither saving some specific info
	   nor simply logging this event.
*/
class AssertException
	: public SteelException
	, public std::runtime_error
{
	//TODO: Call stack should be added.
public:
	AssertException(const std::string&);

	virtual const char* what() const throw();
};

} //namespace Cmn
} //namespace Core

#endif //_ASSERT_H_INCLUDED_